<!DOCTYPE html>
<html>
<head>
<title>赠送积分</title>
[#include "/WEB-INF/admin/include/common.html"]
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>赠送积分, 可用积分：${totalIntegration}</h5>
            </div>
           <form id="inputForm" action="save" method="post">
               <input type="hidden" id="mobile" name="mobile" value="${mobile}" />

                <div class="ibox-content">
                    <div class="form-horizontal clearfix">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">类型：</label>
                            <div class="col-sm-3">
                                <select class="form-control" id="type" name="type">
                                    <option value="1">管理员赠送</option>
                                    <option value="2">购物赠送</option>
                                    <option value="3">已使用</option>
                                </select>
                            </div>
                        </div>
                         <div class="form-group">
                            <label class="col-sm-3 control-label">积分：</label>
                            <div class="col-sm-3">
                                <input placeholder="积分" class="form-control" type="text" name="score" id="score">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">原因：</label>
                            <div class="col-sm-3">
                                <input placeholder="原因" class="form-control" type="text" name="reson" id="reson">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer col-sm-3 col-sm-offset-2">
                    <button type="submit" class="btn btn-w-m btn-primary">确定</button>
                    <button type="button" class="btn btn-w-m btn-default" onclick="history.back(); return false;">取消</button>
                </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

    var $inputForm = $("#inputForm");
    
    // 表单验证
    $inputForm.validate({
        rules: {
            "score": {
                required: true
            }
        },
        submitHandler:function(form){
            if($("#type").val() == 3){
                if(parseInt($("#score").val()) > parseInt('${totalIntegration}')){
                    alert("积分不足");
                    return false;
                }
            }
            form.submit();
        }
    });

});
</script>